<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
  </head>
  <body>
    <style>
      ul {
        list-style: none;
      }
    </style>
    <ul></ul>

    <script>
      var ul = document.querySelector('ul')
      var person = { sex: '男', age: '25', name: '王大锤', height: 28, weight: 32 }
      const _render = (element) => {
        var str = `<li>姓名：<span>${person.name}</span></li>
                           <li>性别：<span>${person.sex}</span></li>
                           <li>年龄：<span>${person.age}</span></li>
                           <li>身高：<span>${person.height}</span></li>
                           <li>体重：<span>${person.weight}</span></li>`
        element.innerHTML = str
      }
      _render(ul)
      // 补全代码
      Object.keys(person).forEach((key) => {
        var value = person[key]
        Object.defineProperty(person, key, {
          get() {
            return value
          },
          set(newVal) {
            value = newVal
            _render(ul)
          },
        })
      })
    </script>
  </body>
</html>
